Public Class frmLoadEmployees 
    Public Sub New(ByVal Emps As EmployeeList, ByVal pth As String)
        MyBase.New()
        InitializeComponent()
        _EmployeesToLoad = Emps
        lbEmployees.Items.AddRange(Emps.ToArray)
        SetAllChecked(True)
        If String.IsNullOrEmpty(My.Settings.BossPublicKey) Then
            picOfficial.Image = My.Resources.Keys64
            picOfficial.ToolTip = "You need to import your boss key to verify official schedules."
        Else
            If Emps.Boss.VerifySignature(pth, My.Settings.BossPublicKey) Then
                picOfficial.Image = My.Resources.OfficialSchedule
                picOfficial.ToolTip = "The file is an official schedule."
            Else
                picOfficial.Image = My.Resources.UnOfficialSchedule
                picOfficial.ToolTip = "The file is not an official schedule made by the boss."
            End If
        End If
        Dim bmap As Bitmap = picOfficial.Image
        bmap.MakeTransparent()
        picOfficial.Image = bmap


    End Sub
    Public ReadOnly Property DoMerge() As Boolean
        Get
            Return chkMerge.Checked
        End Get
    End Property
    Public Enum MergeTypes
        Name
        ID
    End Enum
    Public ReadOnly Property MergeType() As MergeTypes
        Get
            Return optMergeType.SelectedIndex
        End Get
    End Property
    Private _EmployeesToLoad As EmployeeList
    Public ReadOnly Property EmployeesToLoad() As EmployeeList
        Get
            Dim emps As New EmployeeList()
            emps.Holidays = _EmployeesToLoad.Holidays
            emps.WorkHours = _EmployeesToLoad.WorkHours

            For x As Integer = 0 To lbEmployees.CheckedIndices.Count - 1
                emps.Add(lbEmployees.Items(lbEmployees.CheckedIndices(x)).Value)
            Next

            Return emps
        End Get
        
    End Property

    Private Sub SetAllChecked(ByVal Checked As Boolean)
        For x As Integer = 0 To lbEmployees.Items.Count - 1
            lbEmployees.SetItemChecked(x, Checked)
        Next
    End Sub
    Private ModifyChecks As Boolean = True
    Private Sub chkAll_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkAll.CheckedChanged
        If ModifyChecks Then SetAllChecked(chkAll.Checked)
    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Me.DialogResult = Windows.Forms.DialogResult.OK
        Me.Close()
    End Sub

    Private Sub SimpleButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton1.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
        Me.Close()
    End Sub

    Private Sub lbEmployees_ItemCheck(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.ItemCheckEventArgs) Handles lbEmployees.ItemCheck
        ModifyChecks = False
        If lbEmployees.CheckedIndices.Count = 0 Then
            chkAll.Checked = False
        ElseIf lbEmployees.CheckedIndices.Count = lbEmployees.ItemCount Then
            chkAll.Checked = True
        Else
            chkAll.CheckState = CheckState.Indeterminate
        End If
        ModifyChecks = True
    End Sub
End Class